<template>
  <div class="login-page">
     <van-nav-bar class="title"
        title="账号注册"
     />
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        placeholder="请输入账号"
        :rules="[
          {required: true, message: '请填写用户名' },
          {pattern :/\d{5,}$/,message: '用户名至少五个字符'},
        ]"
      />
        <!-- {pattern :/\d{6}/,message: '用户名错误'} -->
      <van-field
        v-model="password"
        type="password"
        name="password"
        placeholder="请输入密码"
        :rules="[
          { required: true, message: '请填写密码' },
          {pattern :/\d{6,}$/,message: '密码至少六个字符'},
        ]"
      />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit" style="border-radius:0">注册</van-button>
      </div>
    </van-form>
    <router-link class="link" to="/login">已注册，请登录~</router-link>
  </div>

</template>

<script>
export default {
  name: 'register-page',
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    onSubmit (val) {
      console.log('val', val)
    }
  }
}
</script>

<style lang="less" scoped>
.title{
  background-color: #1cb676;
  color: #fff;
}
.link {
  color: #666;
  font-size: 12px;
  padding-left: 20px;
  float: left;
}
</style>
